import search from "./search/search.js";
import allOrder from "./allOrder/allOrder.vue";
import successfulTrade from "./successfulTrade/successfulTrade.vue";
import closeTrade from "./closeTrade/closeTrade.vue";

const tabName = [
    "全部订单",
    "交易成功",
    "交易关闭"
]
export default {
    mixins: [search],
    components: {
        allOrder,
        successfulTrade,
        closeTrade
    },
    data() {
        return {
            keyName: "1",
            tab: {
                allOrder: "全部订单",
                successfulTrade: "交易成功",
                closeTrade: "交易关闭"
            },
            tabPosition: 'left',
        }
    },
    mounted() {
        this.getList()
    },
    methods: {
        callback(key) {
            this.keyName = key
            switch (key) {
                case '1':
                    this.$refs.allOrder.getList() //全部订单列表
                    break;
                case '2':
                    this.$refs.successfulTrade.getList() //交易成功列表
                    break;
                case '3':
                    this.$refs.closeTrade.getList() //部分退货列表
                    break;
                default:
                    break;
            }
            this.trigger()
        },
        getList() {
            this.$refs.allOrder.getList()       //全部订单列表
            this.$refs.successfulTrade.getList() //交易成功列表
            this.$refs.closeTrade.getList() //交易关闭列表
            this.trigger()
        },
        trigger() {
            this.tab.allOrder = `${tabName[0]}(${this.$refs.allOrder.page.total})`
            this.tab.successfulTrade = `${tabName[1]}(${this.$refs.successfulTrade.page.total})`
            this.tab.closeTrade = `${tabName[2]}(${this.$refs.closeTrade.page.total})`
        }
    }
}